// 封装Promise请求
const post = (url, data = {}) => {
  var promise = new Promise((resolve, reject) => {
    wx.request({
      url: `https://api.apiopen.top/getJoke?page=1&count=2&type=video`,
      data: data,
      method: 'POST',
      header: {
        'content-type': 'application/x-www-form-urlencoded'
      },
      success: res => {
        resolve(res)
      },
      fail: res => {
        reject(res)
        console.log(res)
      }
    })
  }).catch(err => {
    throw err
  })
  return promise
}

module.exports = post
